#!/usr/bin/env php
<?php

use support\Container;
use Webman\Config;
use WebmanTech\LaravelConsole\Kernel;

require __DIR__.'/vendor/autoload.php';

// same as webman/console
if (!in_array($argv[1] ?? '', ['start', 'restart', 'stop', 'status', 'reload', 'connections'])) {
    require_once __DIR__ . '/support/bootstrap.php';
} else {
    if (class_exists('Support\App')) {
        Support\App::loadAllConfig(['route']);
    } else {
        Config::reload(config_path(), ['route', 'container']);
    }
}

$kernel = Container::get(Kernel::class);
$status = $kernel->handle(
    $input = new Symfony\Component\Console\Input\ArgvInput,
    new Symfony\Component\Console\Output\ConsoleOutput
);

exit($status);
